﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace X13.AI
{
    public struct Waypoint3D
    { 
        //Methods
		private Vector3 _WaypointPosition;
        public Vector3 WaypointPosition
		{
			get { return _WaypointPosition; }
			set { _WaypointPosition = value; }
		}

        //cTor
        public Waypoint3D(Vector3 position)
        {
            _WaypointPosition = position;
        }

        public Vector3 DistanceTo(Waypoint3D b)
        {
            return GetDistanceBetween(this, b);
        }
        public double AngleTo(Waypoint3D b)
        {
            return GetAngleBetween(this, b);
        }

        //Overloads
        public static Waypoint3D operator -(Waypoint3D a, Waypoint3D b)
        {
            return new Waypoint3D(a._WaypointPosition - b._WaypointPosition);
        }
        public static implicit operator Vector3(Waypoint3D a)
        {
            return a._WaypointPosition;
        }
        public static implicit operator Waypoint3D(Vector3 a)
        {
            return new Waypoint3D(a);
        } 

        //Statics
        public static double GetAngleBetween(Waypoint3D a, Waypoint3D b)
        {
            return Math.Atan2(b._WaypointPosition.Y - a._WaypointPosition.Y, b._WaypointPosition.X - a._WaypointPosition.X);
        }
        public static Vector3 GetDistanceBetween(Waypoint3D a, Waypoint3D b)
        {
            return b - a;
        }
    }
}
